package com.bougaga.opensource.scheduler.example.config;

import com.bougaga.opensource.scheduler.core.scheduler.DelayedTaskScheduler;
import com.bougaga.opensource.scheduler.core.task.DelayedTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;

/**
 * 示例配置类
 * 
 * @author bougaga
 * @since 1.0.0
 */
@Configuration
public class ExampleConfig implements CommandLineRunner {
    
    private static final Logger logger = LoggerFactory.getLogger(ExampleConfig.class);
    
    private final DelayedTaskScheduler scheduler;
    
    @Autowired
    public ExampleConfig(DelayedTaskScheduler scheduler) {
        this.scheduler = scheduler;
    }
    
    @Override
    public void run(String... args) throws Exception {
        logger.info("Starting Bou Scheduler Example...");
        
        // 启动调度器
        scheduler.start();
    }
}
